<?

require('./View/ViewFunctions.php');
require('./View/Security.php');
require('./View/ShowTable.php');

 $textSearch = $_GET['textSearch'];
if($_GET['textSearch'] != "" ) {
 	$textSearchString = " AND (CellType.name REGEXP '$textSearch' OR CellType.Species REGEXP '$textSearch' OR CellType.Media REGEXP '$textSearch' OR CellType.Culture REGEXP '$textSearch' OR CellType.ThawTechnique REGEXP '$textSearch' OR FrozenTube.Note REGEXP '$textSearch' OR FrozenTube.PassageFrozen REGEXP '$textSearch' OR FrozenTube.NumberFrozen REGEXP '$textSearch' OR Modification.Name REGEXP '$textSearch' Or Modification.Description  REGEXP '$textSearch' OR Researcher.Name REGEXP '$textSearch' OR Researcher.Email REGEXP '$textSearch')";
 		
  }
 unset($_GET['textSearch']);
$query = 'SELECT * FROM Researcher';
$tables = 'FrozenTube JOIN CellType ON(FrozenTube.CellTypeID=CellType.id) JOIN Container ON (FrozenTube.ContainerID=Container.id) JOIN Modification ON (Modification.id=FrozenTube.ModifiedByID) JOIN Researcher ON(Researcher.id=FrozenTube.FrozenByID)';
$result = selectFromDatabase(array('FrozenTube.CellTypeID, CellType.Name AS "CellType", FrozenTube.ModifiedByID AS "ModificationID", Modification.Name AS "Modification", FrozenTube.FrozenByID AS "ResearcherID", Researcher.Name AS "Researcher", FrozenTube.PassageFrozen AS "Passage", FrozenTube.NumberFrozen AS "Number Frozen", Container.Tank, Container.Tower, FrozenTube.ContainerID, Container.Position, FrozenTube.ContainerID'),  $tables,  $_GET, $textSearchString);
$_GET['textSearch'] = $textSearch;
$extraLinks = makeSearchLink($_GET);



$table = new ShowTable();
$select = $table->displayData($result, array('CellTypeID' => 'ViewGeneric.php', 'ModificationID' =>'ViewGeneric.php', 'ResearcherID' => 'ViewGeneric', 'ContainerID' => 'ViewBox.php'), $extraLinks );
echo $select
?>
